# 202. 快乐数
def isHappy(self, n):
  # def getNext(n):
  #   return sum(int(char)**2 for char in str(n))

  # list=[]
  # total=n
  # while total not in list and total!=1:
  #   list.append(total)
  #   total=getNext(total)
  # else:
  #   return total==1
# 弗洛伊德循环
  def getNext(n):
    return sum(int(char)**2 for char in str(n))
  slow,fast=n,getNext(n)
  while slow!=fast and fast!=1:
    slow=getNext(slow)
    fast=getNext(getNext(fast))
  else:
    return fast==1

